package nc.tb.excel.ctl;

import nc.tb.cube.cell.AreaPosition;

public class POIExcelSheet implements IExcelSheet {
	
	private org.apache.poi.hssf.usermodel.HSSFSheet sheet = null;

	public POIExcelSheet(org.apache.poi.hssf.usermodel.HSSFSheet _sheet) {
		sheet = _sheet;
	}

	public int getFirstRowNum() {
		return sheet.getFirstRowNum();
	}

	public int getLastRowNum() {
		return sheet.getLastRowNum();
	}

	public int getNumMergedRegions() {
		return sheet.getNumMergedRegions();
	}

	public AreaPosition getAreaPositionFromMergedRegionAt(int idx) {
		AreaPosition ap = null;
		org.apache.poi.hssf.util.Region rg = sheet.getMergedRegionAt(idx);
		ap = new AreaPosition(rg.getRowFrom(), rg.getColumnFrom(), rg.getRowTo(), rg.getColumnTo());
		return ap;
	}
	
	public short getRowFirstCellNum(int rowIdx) {
		org.apache.poi.hssf.usermodel.HSSFRow row = sheet.getRow(rowIdx);
		return row.getFirstCellNum();
	}
	
	public short getRowLastCellNum(int rowIdx) {
		org.apache.poi.hssf.usermodel.HSSFRow row = sheet.getRow(rowIdx);
		return row.getLastCellNum();
	}
	
	public boolean hasRow(int rowIdx) {
		org.apache.poi.hssf.usermodel.HSSFRow row = sheet.getRow(rowIdx);
		return row != null;
	}

}
